package com.ysd.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.dao.impl.XinWenDaoImpl;
import com.ysd.dao.impl.XinWenLieBieDaoImpl;
import com.ysd.entity.XinWen;
import com.ysd.entity.XinWenLieBie;


public class NewsServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//新闻分类 
		XinWenLieBieDaoImpl xwlbDao=new XinWenLieBieDaoImpl();
		List<XinWenLieBie> xwlbList = xwlbDao.getXinWenLieBieList();
		request.setAttribute("xwlbList", xwlbList);
		
		//接受前台传来参数
		//根据新闻分类Id查询对应的产品
		
		int xwId = Integer.parseInt(request.getParameter("xwwaiJianId"));
		XinWenDaoImpl xwDao = new XinWenDaoImpl();
		List<XinWen> xinwenList = xwDao.getXinWenList(xwId);
		request.setAttribute("xinwenList",xinwenList );
		
		request.getRequestDispatcher("article_list.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		doGet(request, response);
	}

}
